package com.itheima.myfile.test2;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.Socket;

public class ClientDome {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("127.0.0.1", 10000);
        //通过socket对象获得输出流
        OutputStream os = socket.getOutputStream();
        //写数据
        os.write("hello".getBytes());
        //此处关闭流,但是不关闭socket
        socket.shutdownOutput();

        //从服务器那边接收反馈用字符接收
        BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        //读取信息
        String line;
        while ((line = br.readLine())!=null){
            System.out.println(line);
        }
        //关流
        br.close();
        socket.close();


    }
}
